@echo off
setlocal enabledelayedexpansion

REM Get current commit hash
for /f %%i in ('git rev-parse HEAD') do set current=%%i

REM Initialize flag
set found=false

REM Loop through commits from oldest to newest on main branch
for /f %%j in ('git rev-list --reverse main') do (
    if "!found!"=="true" (
        echo Switching to next commit: %%j
        git checkout %%j
        goto :eof
    )
    if "%%j"=="%current%" (
        set found=true
    )
)

echo Already at the latest commit. No next commit.
